package IO;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

public class WriteStringDemo {
    public static void main(String[] args) throws IOException {
     /*   FileOutputStream fos = new FileOutputStream("./File/fos.txt");
        FileInputStream fis = new FileInputStream("./File/fos.txt");
        String line = "先帝创业未半";
        //原始写入
        byte[] date = line.getBytes(StandardCharsets.UTF_8);
        fos.write(date);
        //精简写入，数组和写入融合为一句
        line = "，而半道崩殂";
        fos.write(line.getBytes(StandardCharsets.UTF_8));
        */
        FileOutputStream fos = new FileOutputStream("./File/fos.txt",true);
        fos.write("然侍卫之臣不懈于内，忠志之士忘身于外者".getBytes(StandardCharsets.UTF_8));
        fos.write("，盖追先帝之殊遇，欲报之于陛下也。".getBytes(StandardCharsets.UTF_8));
        System.out.println("写出完毕");
        fos.close();
//        fis.read();
    }
}
